package com.tony.activotytest;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.SeekBar;
import android.widget.TextView;

public class SimpleComponentActivity extends AppCompatActivity {
    private ProgressBar pbHorizontal;
    private SeekBar seekBar;
    private TextView tvProgress;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_simple_component);

        initView();
    }

    public void initView(){
        pbHorizontal = findViewById(R.id.pb_horizontal);
        seekBar = findViewById(R.id.seekbar);
        tvProgress = findViewById(R.id.tv_propress);

        seekBar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
                pbHorizontal.setProgress(progress);
                tvProgress.setText("当前进度:"+progress+"%");
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                if( pbHorizontal.getProgress() >= pbHorizontal.getMax()){
                    pbHorizontal.setVisibility(View.GONE);
                }else {
                    pbHorizontal.setVisibility(View.VISIBLE);
                }
            }
        });


    }


}